
import os
import subprocess


def test_os_popen():
    stream = os.popen('ls -alth ~/')
    output = stream.read()
    print(output)


def test_subprocess():
    cmd = "pwd;exit 0"
    result = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    child = result.communicate()
    print(result.returncode)


if __name__ == "__main__":
    test_subprocess()